package com.fuxi.cloud.config.oss;

import com.fuxi.cloud.common.util.OssBootUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * JimuOssConfiguration
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */

@Component("jimuOssConfiguration")
@ConfigurationProperties(
        prefix = "jeecg.oss"
)
@ConditionalOnProperty(
        value = {"jeecg.uploadType"},
        havingValue = "alioss",
        matchIfMissing = true
)
public class JimuOssConfiguration {
    private String endpoint;
    private String accessKey;
    private String secretKey;
    private String bucketName;
    private String staticDomain;

    @Bean
    public void initJimuOssBootConfiguration() {
        OssBootUtil.setEndPoint(this.endpoint);
        OssBootUtil.setAccessKeyId(this.accessKey);
        OssBootUtil.setAccessKeySecret(this.secretKey);
        OssBootUtil.setBucketName(this.bucketName);
        OssBootUtil.setStaticDomain(this.staticDomain);
    }

    public JimuOssConfiguration() {
    }

    public String getEndpoint() {
        return this.endpoint;
    }

    public String getAccessKey() {
        return this.accessKey;
    }

    public String getSecretKey() {
        return this.secretKey;
    }

    public String getBucketName() {
        return this.bucketName;
    }

    public String getStaticDomain() {
        return this.staticDomain;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }

    public void setStaticDomain(String staticDomain) {
        this.staticDomain = staticDomain;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof JimuOssConfiguration)) {
            return false;
        } else {
            JimuOssConfiguration var2 = (JimuOssConfiguration)o;
            if (!var2.canEqual(this)) {
                return false;
            } else {
                label71: {
                    String var3 = this.getEndpoint();
                    String var4 = var2.getEndpoint();
                    if (var3 == null) {
                        if (var4 == null) {
                            break label71;
                        }
                    } else if (var3.equals(var4)) {
                        break label71;
                    }

                    return false;
                }

                String var5 = this.getAccessKey();
                String var6 = var2.getAccessKey();
                if (var5 == null) {
                    if (var6 != null) {
                        return false;
                    }
                } else if (!var5.equals(var6)) {
                    return false;
                }

                label57: {
                    String var7 = this.getSecretKey();
                    String var8 = var2.getSecretKey();
                    if (var7 == null) {
                        if (var8 == null) {
                            break label57;
                        }
                    } else if (var7.equals(var8)) {
                        break label57;
                    }

                    return false;
                }

                String var9 = this.getBucketName();
                String var10 = var2.getBucketName();
                if (var9 == null) {
                    if (var10 != null) {
                        return false;
                    }
                } else if (!var9.equals(var10)) {
                    return false;
                }

                String var11 = this.getStaticDomain();
                String var12 = var2.getStaticDomain();
                if (var11 == null) {
                    if (var12 == null) {
                        return true;
                    }
                } else if (var11.equals(var12)) {
                    return true;
                }

                return false;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof JimuOssConfiguration;
    }

    @Override
    public int hashCode() {
        boolean var1 = true;
        byte var2 = 1;
        String var3 = this.getEndpoint();
        int var8 = var2 * 59 + (var3 == null ? 43 : var3.hashCode());
        String var4 = this.getAccessKey();
        var8 = var8 * 59 + (var4 == null ? 43 : var4.hashCode());
        String var5 = this.getSecretKey();
        var8 = var8 * 59 + (var5 == null ? 43 : var5.hashCode());
        String var6 = this.getBucketName();
        var8 = var8 * 59 + (var6 == null ? 43 : var6.hashCode());
        String var7 = this.getStaticDomain();
        var8 = var8 * 59 + (var7 == null ? 43 : var7.hashCode());
        return var8;
    }

    @Override
    public String toString() {
        return "JimuOssConfiguration(endpoint=" + this.getEndpoint() + ", accessKey=" + this.getAccessKey() + ", secretKey=" + this.getSecretKey() + ", bucketName=" + this.getBucketName() + ", staticDomain=" + this.getStaticDomain() + ")";
    }
}

